﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Model;
using EntityServices;
using System.Web.Http.Cors;

namespace WebApp1.Controllers
{
    [EnableCors(origins:"*",headers:"*",methods:"*")]
    public class 系部Controller : ApiController
    {
         TimeTableOneEntityServicesFactory entityServices = new TimeTableOneEntityServicesFactory();
        // GET api/<controller>
        public IEnumerable<系部> Get()
        {
            return  entityServices.系部Service.GetList();
        }

        [HttpGet]
        [Route ("api/系部/{dId}/班级")]
        public IEnumerable<班级> GetClass(int dId)
        {
            系部 temp= entityServices.系部Service.GetById(dId);
            if (temp != null)
                return temp.班级;
            return null;
        }

        // GET api/<controller>/5
        public string Get(int id)
        {
            return "value";
        }

        [Route("api/系部/{id}")]
        // POST api/<controller>
        public void Post([FromBody]系部 value,int id)
        {
            value.学院Id = id;
            entityServices.系部Service.NewSave(value);
        }

        // PUT api/<controller>/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/<controller>/5
        public void Delete(int id)
        {
        }
    }
}